﻿using System;
using Autodesk.Revit.DB;

namespace YJKAcquireDataComparison
{
	internal class TextNoteGeoObject : GeoObjectBase
	{
		public TextNoteGeoObject(Element inputElement)
		{
			base.GeoObjType = EGeoObjectType.eTextNoteObj;
			this.InitDataByElement(inputElement);
		}

		public override void InitDataByElement(Element inputElement)
		{
			TextNote textNote = inputElement as TextNote;
			if (textNote == null)
			{
				base.BoundingRect.LeftBottom = XYZ.Zero;
				base.BoundingRect.RightTop = XYZ.Zero;
				return;
			}
			this.InitBoundingBoxRectByTextNote(textNote);
		}

		private void InitBoundingBoxRectByTextNote(TextNote textNote)
		{
			XYZ coord = textNote.Coord;
			XYZ baseDirection = textNote.BaseDirection;
			XYZ xyz = -textNote.UpDirection;
			Autodesk.Revit.DB.View view = textNote.Document.GetElement(textNote.OwnerViewId) as Autodesk.Revit.DB.View;
			double num = textNote.Width * (double)view.Scale;
			XYZ rightTop = coord.Add(baseDirection * num).Add(xyz * num);
			base.BoundingRect.LeftBottom = coord;
			base.BoundingRect.LeftTop = coord.Add(xyz * num);
			base.BoundingRect.RightTop = rightTop;
			base.BoundingRect.RightBottom = coord.Add(baseDirection * num);
		}

		public override bool Equals(object obj)
		{
			return base.Equals(obj);
		}
	}
}
